package com.wanpinghui.supplier.message.nim;

import com.alibaba.fastjson.JSONObject;

/**
 * Created by xiongning on 17-12-5.
 */

public class WPHMsg extends WPHAttachment {

    public static final int MSG_TXT = 0;//聊天信息类型是文本

    public static final int MSG_IMG = 1;//聊天信息类型是图片

    public static final int MSG_DOC = 2;//聊天信息类型是文件

    public static final int MSG_VOICE = 3;//聊天信息类型是语音

    public static final int MSG_ORDER = 4;//聊天信息类型是订单

    public static final int MSG_BID_SUCCESS = 5;//聊天信息类型是抢单成功提醒

    public static final int MSG_BID_RECHARGE = 6;//聊天信息类型是充值提醒

    public static final int MSG_BID_FOLLOW = 7;//聊天信息类型是跟进提醒



    private String msg;

    private int type = MSG_TXT;//聊天信息类型

    private String ext;

    public WPHMsg(int msg_type) {
        super(msg_type);
    }

    public WPHMsg(int msg_type, int type, String messages) {
        super(msg_type);
        this.type = type;
        this.msg = messages;
    }

    public WPHMsg(int msg_type, String msg, int type, String extJson) {
        super(msg_type);
        this.msg = msg;
        this.type = type;
        this.ext = extJson;
    }

    @Override
    protected void parseData(JSONObject data) {
        type = data.getInteger("type");
        msg = data.getString("msg");
        ext = data.getString("ext");
    }

    @Override
    protected JSONObject packData() {
        JSONObject data = new JSONObject();
        data.put("type", type);
        data.put("msg", msg);
        data.put("ext", ext);
        return data;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getMsg() {
        return msg;
    }

    public int getType() {
        return type;
    }

    public String getExt() {
        return ext;
    }

    public void setExt(String ext) {
        this.ext = ext;
    }
}
